using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using System.Collections.ObjectModel;
using CPlatePrintSys.Win.ViewModels;

namespace CPlatePrintSys.Win.Converters
{
    public class DistinctStreamShipNoConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var list = value as ObservableCollection<PlateAnnotationInfoViewModel>;
            if (list == null) return new[] { "全部" };
            var result = list.Select(x => x.StreamShipNo).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
            result.Insert(0, "全部");
            return result;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
} 